#include "Network/Socket.h"
#include "Util/logger.h"
#include "zlmediaz.h"
#include <signal.h>
#include <sys/stat.h>

using namespace std;
using namespace toolkit;

int main(int argc, char const *argv[]) {
    Logger::Instance().add(std::make_shared<ConsoleChannel>());
    Logger::Instance().add(std::make_shared<FileChannel>());
    Logger::Instance().setWriter(std::make_shared<AsyncLogWriter>());

    InfoL << "程序启动 Start ...";

    InterfaceMediaz::Instance().InitLib();

    InterfaceMediaz::Instance().addStreamProxy("APP", "Stream", "rtsp://admin:pdfpdf12@192.168.0.6:554/streaming/channels/301");

    static semaphore sem;
    signal(SIGINT, [](int) {
        InfoL << "SIGINT:exit";
        signal(SIGINT, SIG_IGN);
        sem.post();
    });

    sem.wait();

    InfoL << "The program is exiting, please wait...";

    sleep(1);
    InfoL << "exit ok!";
    return 0;
}
